{template 'web/_header'}
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createPluginWebUrl('express/express')}">快递预处理</a></li>
    <li class=""><a href="{php echo $this->createPluginWebUrl('express/shipment')}">批量发货</a></li>
</ul>

<div class="main">
    <form action="{php echo $this->createPluginWebUrl('express/express', array('op' => 'editor'))}" method="post" class="form-horizontal form">
        <input type="hidden" name="express[id]" value="{$express['id']}" />
        <div class='panel panel-default'>
            <div class='panel-heading'>
                快递预处理基础配置
            </div>

            <div class='panel-body'>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 所属配送方式</label>
                    <div class="col-sm-9 col-xs-12">
                        <select class="form-control" name="express[dispatchid]" {if $express['id'] != ''}disabled{/if}>
                        {loop $dispatchLists $list}
                            <option value="{$list['id']}" {if $express['dispatchid'] == $list['id']}selected="selected" {/if} >{$list['dispatchname']}</option>
                        {/loop}
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 发件人</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="express[sender]" class="form-control" value="{$express['sender']}" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 手机</label>
                  <div class="col-sm-9 col-xs-12">
                        <input type="text" name="express[phone]" class="form-control" value="{$express['phone']}" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 发货地</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_district('express[area]', array('province' => $express['province'], 'city' => $express['city'], 'district' => $express['district'] ));}
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 详细地址</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="express[address]" class="form-control" value="{$express['address']}" />
                    </div>
                </div>
            </div>

            <div class="panel-footer" style="overflow: auto;">
                <div class="form-group col-sm-12">
                    <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
                    <input type="hidden" name="token" value="{$_W['token']}" />
                </div>
            </div>

        </div>
    </form>
</div>


<script type="text/javascript">
    $('.form').submit(function(){
        var dispatchid = $("select[name='express[dispatchid]']").find("option:selected").val();

        if(dispatchid == ''){
            Tip.focus($("select[name='express[dispatchid]']"),'请选择配送方式!');
            return false;
        }

        var sender = $("input[name='express[sender]']").val();
        if(sender == ''){
            Tip.focus($("input[name='express[sender]']"),'请输入发件人姓名!');
            return false;
        }

        var phone = $("input[name='express[phone]']").val();
        if(phone == ''){
            Tip.focus($("input[name='express[phone]']"),'请输入发件人手机!');
            return false;
        }

        phoneReg = /^1\d{10}$/;
        if (!phoneReg.test(phone)) {
            Tip.focus($("input[name='express[phone]']"),'请输入正确的手机号码!');
            return false;
        }

        var address = $("input[name='express[address]']").val();
        if(address == ''){
            Tip.focus($("input[name='express[address]']"),'请输入发件人的详细地址!');
            return false;
        }

        var province = $("select[name='express[area][province]']").find("option:selected").val();

        if(province == ''){
            Tip.focus($("select[name='express[area][province]']"),'请选择正确的发货地!');
            return false;
        }

        var city = $("select[name='express[area][city]']").find("option:selected").val();
        if(city == ''){
            Tip.focus($("select[name='express[area][city]']"),'请选择正确的发货地!');
            return false;
        }

        var district = $("select[name='express[area][district]']").find("option:selected").val();
        if(district == ''){
            Tip.focus($("select[name='express[area][district]']"),'请选择正确的发货地!');
            return false;
        }

        return true;
    });
</script>

{template 'common/footer'}